﻿using RSFrame.Services;
using RSModels;
using RSModels.Data;
using System;
using System.Collections.Generic;

namespace TaskDistributionService
{
    class TaskDistributionService : ITaskDistributionService
    {
        public string[] StageContent { get; set; } = { "前往", "到达目的地，准备装运垃圾", "装运完成，准备完成下一个任务。" };

        public List<RSTask> GenerateTasks(List<Appointment> appointments)
        {
            if (appointments == null)
                return null;
            else
            {
                List<RSTask> result = new();
                foreach (var item in appointments)
                {
                    result.Add(new RSTask()
                    {
                        Content = StageContent[0] + item.Address,
                        Stage = 0,
                        SourceAppointmentID = item.ID
                    });
                    result.Add(new RSTask()
                    {
                        Content = StageContent[1],
                        Stage = 1,
                        SourceAppointmentID = item.ID
                    });
                    result.Add(new RSTask()
                    {
                        Content = StageContent[2],
                        Stage = 2,
                        SourceAppointmentID = item.ID
                    });
                }
                return result;
            }
        }

        public bool IsInServiceRegion(float driverLng, float driverLat, float appointmentLng, float appointmentLat)
        {
            return true;
        }
    }
}
